package com.game.battleship;



import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainMenuActivity extends Activity {

//	private static final int OPTION_QUICK_GAME = 0;
//	private static final int OPTION_SINGLE_PLAYER = 1;
//	private static final int OPTION_MULTI_PLAYER = 2;
//	private static final int OPTION_OPTIONS = 3;
//	private static final int OPTION_CREDITS = 4;
//	private static final int OPTION_QUIT = 5;
	
	private static final int OPTION_QUICK_GAME = 0;
	private static final int OPTION_SINGLE_PLAYER = 1;
	private static final int OPTION_OPTIONS = 2;
	private static final int OPTION_CREDITS = 3;
	private static final int OPTION_QUIT = 4;
	
	String[] mainMenuOptions;	
	ListView mainMenuOptions_ListView;
	ArrayAdapter<String> mainMenuOptions_ArrayAdapter;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_menu);
        
        mainMenuOptions_ListView = (ListView)this.findViewById(R.id.mainMenuOptions_ListView);
        
        Resources rsc = this.getResources();
        mainMenuOptions = rsc.getStringArray(R.array.main_menu_options);
        
        mainMenuOptions_ArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mainMenuOptions);
        mainMenuOptions_ListView.setAdapter(mainMenuOptions_ArrayAdapter);
        
        
        mainMenuOptions_ListView.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
				// TODO Auto-generated method stub
				switch (pos) {
				case OPTION_QUICK_GAME:
//					Toast.makeText(getBaseContext(), "Quick Game", Toast.LENGTH_SHORT).show();
					goToQuickGameSettingsActivity();
					break;
				case OPTION_SINGLE_PLAYER:
					//Toast.makeText(getBaseContext(), "Single-player", Toast.LENGTH_SHORT).show();
					goToSinglePlayerMenuActivity();
					break;
//				case OPTION_MULTI_PLAYER:
//					Toast.makeText(getBaseContext(), "Multi-player", Toast.LENGTH_SHORT).show();
//					goToMultiPlayerActivity();
//					break;
				case OPTION_OPTIONS:
//					Toast.makeText(getBaseContext(), "Multi-player", Toast.LENGTH_SHORT).show();
					goToOptionsActivity();
					break;
				case OPTION_CREDITS:
					//Toast.makeText(getBaseContext(), "Credits", Toast.LENGTH_SHORT).show();
					goToCreditsActivity();
					break;
				case OPTION_QUIT:
					finish();
					break;
				}
			}
        	
        });
    }

	protected void goToOptionsActivity() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(MainMenuActivity.this, OptionsActivity.class);
		startActivity(intent);
	}

//	protected void goToMultiPlayerActivity() {
//		// TODO Auto-generated method stub
//		Intent intent = new Intent(MainMenuActivity.this, MultiPlayerActivity.class);
//		startActivity(intent);
//	}

	protected void goToQuickGameSettingsActivity() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(MainMenuActivity.this, QuickGameSettingsActivity.class);
		startActivity(intent);
	}

	protected void goToSinglePlayerMenuActivity() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(MainMenuActivity.this, SinglePlayerMenuActivity.class);
		startActivity(intent);
	}

	private void goToCreditsActivity() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(MainMenuActivity.this, CreditsActivity.class);
		startActivity(intent);
	}
}
